/*
 * PKL 51 GUNUNG KIDUL
 * Subseksie DATA ENTRY + CAPI
 */
package pkl51.validasi;

import pkl51.component.TextField;
import pkl51.view.kuesioner.PanelBlok6C;

/**
 *
 * @author tyas
 */
public class ValidasiBlok6C extends AbstractValidasi{
    private PanelBlok6C panelBlok6C;
    
    public void setPanelBlok6C(PanelBlok6C panelBlok6C) {
        this.panelBlok6C = panelBlok6C;
    }

    public ValidasiBlok6C() {
    }
    
    public void registerValidator() {
        panelBlok6C.getTxtB6CR18().setValidator(new ValidasiB6CR18());
        panelBlok6C.getTxtB6CR1().setValidator(new ValidasiB6CR1());
        panelBlok6C.getTxtB6CR3().setValidator(new ValidasiB6CR3());
        
    }
    
    private class ValidasiB6CR1 implements Validator {

        @Override
        public boolean onCheckValue(TextField field) {
            if (field.getInt() == 0) {
                errorMessage("Sewa,kontrak, perkiraan sewa rumah (milik sendiri, dinas), dll Tidak boleh 0");
                return false;
            }
            return true;
        }
    
    }
    
    private class ValidasiB6CR3 implements Validator {

        @Override
        public boolean onCheckValue(TextField field) {
            if (field.getInt() == 0) {
                errorMessage("Rekening listrik, air, gas, minyak tanah, kayu bakar, dll Tidak boleh 0");
                return false;
            }
            return true;
        }
    
    }
    
    private class ValidasiB6CR18 implements Validator {
        @Override
        public boolean onCheckValue(TextField field) {
            if (field.getInt() == panelBlok6C.getTxtB6CR1().getInt() + panelBlok6C.getTxtB6CR2().getInt() + 
                    panelBlok6C.getTxtB6CR3().getInt() + panelBlok6C.getTxtB6CR4().getInt() + 
                    panelBlok6C.getTxtB6CR5().getInt() + panelBlok6C.getTxtB6CR6().getInt() +
                    panelBlok6C.getTxtB6CR7().getInt() + panelBlok6C.getTxtB6CR8().getInt() +
                    panelBlok6C.getTxtB6CR9().getInt() + panelBlok6C.getTxtB6CR10().getInt() +
                    panelBlok6C.getTxtB6CR11().getInt() + panelBlok6C.getTxtB6CR12().getInt() +
                    panelBlok6C.getTxtB6CR13().getInt() + panelBlok6C.getTxtB6CR14().getInt() +
                    panelBlok6C.getTxtB6CR15().getInt() + panelBlok6C.getTxtB6CR16().getInt() + 
                    panelBlok6C.getTxtB6CR17().getInt() ) {
            return true;
        }
            else  {
                errorMessage("Cek kembali jumlah Totalnya !");
                return false; 
            }
        }
    }
}
